//
//  FillInTelPhoneNumberVC.m
//  MRBang
//
//  Created by 铅笔 on 15/12/18.
//  Copyright © 2015年 杭州易网新科技. All rights reserved.
//

#import "FillInTelPhoneNumberVC.h"

@interface FillInTelPhoneNumberVC ()<UITextFieldDelegate>
@property (nonatomic,strong) UITextField *textField_telPhone;
@property (nonatomic,strong) UIButton *button_getcheckCode;

@end

@implementation FillInTelPhoneNumberVC

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = RXDColor(237, 243, 243);
    self.title = @"填写手机号码";
    
    [self initWithAllSubviews];
}

#pragma mark --- 创建视图
- (void) initWithAllSubviews
{
    UILabel *label_text = [[UILabel alloc] initWithFrame:CGRectMake(20,84, kScreenWidth-40, 20)];
    [self.view addSubview:label_text];
    label_text.text = @"请保持您的手机畅通，用于接收验证码短信";
    label_text.font = [UIFont systemFontOfSize:10];
    label_text.textColor = RXDColor(80, 81, 81);
    
    //手机号
    self.textField_telPhone = [[UITextField alloc] initWithFrame:CGRectMake(20, label_text.frame.size.height+label_text.frame.origin.y+20,kScreenWidth - 40, 40)];
    [self.view addSubview:self.textField_telPhone];
    self.textField_telPhone.placeholder = @"  请输入您的手机号码";
    self.textField_telPhone.layer.borderColor = RXDColor(205, 205, 207).CGColor;
    self.textField_telPhone.layer.borderWidth = 1.0;
    self.textField_telPhone.layer.cornerRadius = 3.0;
    self.textField_telPhone.clipsToBounds = YES;
    self.textField_telPhone.returnKeyType = UIReturnKeyDone;
    self.textField_telPhone.delegate = self;
    self.textField_telPhone.backgroundColor = [UIColor whiteColor];

    //button getcheckCode
    self.button_getcheckCode = [[UIButton alloc] initWithFrame:CGRectMake(20, self.textField_telPhone.frame.size.height+self.textField_telPhone.frame.origin.y+15,kScreenWidth - 40, 40)];
    [self.view addSubview:self.button_getcheckCode];
    self.button_getcheckCode.backgroundColor = RXDColor(255, 118, 112);
    [self.button_getcheckCode setTitle:@"获取手机验证码" forState:UIControlStateNormal];
    self.button_getcheckCode.layer.cornerRadius = 3.0;
    self.button_getcheckCode.clipsToBounds = YES;
    
    [self.button_getcheckCode addTarget:self action:@selector(getMobileCheckCodeRequest) forControlEvents:UIControlEventTouchUpInside];
    
}


#pragma mark --- 获得手机验证吗 网络请求
- (void) getMobileCheckCodeRequest
{

    if (self.textField_telPhone.text.length!=11) {
        [BaseViewController showMessage:@"请填写正确手机号"];
        return;
    }
    else
    {
        
        NSDictionary *paras_checkCode = @{@"mobile":self.textField_telPhone.text,@"type":[NSNumber numberWithInt:3]};
        NSString *strURL = [NSString stringWithFormat:@"%@captcha",MRAPI];
        
        [[HttpRequest shardWebUtil] postNetworkRequestURLString:strURL parameters:paras_checkCode success:^(id obj) {
            
            NSLog(@"obj222222%@",obj);
            NSString *str_false = obj[@"error"];
            
            if (str_false.length==0)
            {
                
            }
            else
            {
                [BaseViewController showMessage:str_false];
            }
        } fail:^(NSError *error) {
            
        }];
    }

}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    
}

@end
